<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="__ADMIN__/css/font.css">
<link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
<script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
<script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
<script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
{include file="public/layui" /}
<style>
	.layui-btn+.layui-btn{
    margin-left: 0;
}
</style>
</head>

<body>
<div class="x-body x-admin">
    <form class="layui-form">
	<div class="layui-table-body layui-table-main" style="width: 100%;overflow:hidden">
		<table class="layui-table">
		    <thead>
		        <tr>
		            <td>考核项目</td>
		            {if $typeCheck}
                    <td>维度</td>
                    {/if}
                    <td>项目满分</td>
                    <td>指标要求</td>
                    <td>评分规则</td>
                    {if $selfOn}
                    <td>自评</td>
                    <td>上级</td>
                    {/if}
                    {if $finaOn}
                    <td>自评</td>
                    <td>上级</td>
                    {/if}
		        </tr>
		    </thead>
		    <tbody>
		        {volist name="itemList" id="v"}
		        <tr>
		            <td>{$v.item_name}</td>
		            {if $typeCheck}
                    <td>{$v.type_name}</td>
                    {/if}
                    <td>{$v.max_score}</td>
                    <td>{$v.index_desc}</td>
                    <td>{$v.rule_desc}</td>
                    {if $selfOn}
                    <td>{if $v.self_score == ''}<input type="text" style="width:60px" name="self_score[{$v.id}]" class="scoring_input_1" oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)} if(value < 0 ) {value = 0} if(value > {$v.max_score}) {value = '{$v.max_score}'} ">{else} {$v.self_score} {/if}</td>
                    <td>{$v.final_score}</td>
                    {/if}
                    {if $finaOn}
                    <td>{$v.self_score}</td>
                    <td>{if $v.final_score == ''}<input type="text" style="width:60px" name="final_score[{$v.id}]" class="scoring_input_2" oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)} if(value < 0 ) {value = 0} if(value > {$v.max_score}) {value = '{$v.max_score}'} ">{else} {$v.final_score} {/if}</td>
                    {/if}
		        </tr>
		        <?php $maxScore += $v['max_score']; ?>
		        {/volist}
		    </tbody>
		</table>
		{if $finaOn}
		<table class="layui-table layui-form">
	        <tr>
                <td align="center">绩效工资</td>
	            <td align="center">最终得分<b id="final_score">{$result.final_score?:0}</b> X 绩效工资 <input name="merit_pay" type="number" class="merit_pay" value="{$result.merit_pay?:0}" style="width:60px" {if $result.merit_pay} readonly {/if}> 
	            <td align="center">合计：<span id="merit_pay">{$result.max_score?$result.final_score * $result.merit_pay / $result.max_score:''}</span></td>
	        </tr>
		</table>
		{/if}
		{if ($v.final_score == '' && $finaOn) || ($v.self_score == '' && $selfOn) }
		<div style="text-align:center "><button class="layui-btn layui-bg-blue " type="button" lay-filter="submit" lay-submit=""> 提交 </button></div>
		{/if}
	</div>
	<input name="result_id" value="{$result.id}" type="hidden"> <input name="max_score" value="{$result.max_score?:$maxScore}" type="hidden">
	</form>
	<div class="layui-table-body layui-table-main" style="width: 100%;">
		<table class="layui-table layui-form">
		    <thead>
		        <tr>
		            <td>录入客户数</td>
                    <td>签单客户数</td>
                    <td>活动开启数</td>
                    <td>已报业绩</td>
		        </tr>
		    </thead>
		    <tbody>
		        <tr>
		            <td>{$clientCount}</td>
		            <td>{$qdCount}</td>
		            <td>{$performanceData.count}</td>
		            <td>{$performanceData.sum}</td>
		        </tr>
		    </tbody>
		</table>
	</div>
</div>
<script type="text/html" id="toolbarDemo">

</script> 

<script>
layui.use(['form','layer','jquery','table','util'], function(){
    form = layui.form,
    layer = layui.layer
    ,$ = layui.jquery
    ,table = layui.table
    ,util = layui.util;
    
    $('.scoring_input_2').change(function(){
        var finaScore = 0;
        $('.scoring_input_2').each(function(index, value){
            var s = parseFloat($(this).val()) ;
            if(s > 0)
            {
                finaScore += s;
            }
            $('#final_score').html(finaScore);
            $('#merit_pay').html( (finaScore * parseFloat($('.merit_pay').val()) / 100 ).toFixed(2) );
        })
    })
    $('.merit_pay').change(function(){
        $('#merit_pay').html( ( parseFloat($('#final_score').html()) * parseFloat($(this).val()) / 100 ).toFixed(2) );
    })
    form.on('submit(submit)', function(data){
        $.ajax({
            type:'POST',
            dataType:'json',
            data:data.field,
            url:"",
            success:function(obj){
              layer.alert(obj.msg, {icon: obj.icon},function () {
                  if(obj.icon == 1)
                  {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    x_admin_father_reload();
                  }
                  else
                  {
                      layer.closeAll();
                  }
              });
            }
        });
        return false;
    });
});

</script>
</body>

</html>